/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modulos.examenes.vista;

import java.awt.Image;
import java.io.File;
import javax.swing.ImageIcon;
import vista.frmPrincipal;
import vista.modelo.OperacionesVarias;

/**
 *
 * @author Edulima
 */
public class iFrmVisualizarImagen extends javax.swing.JInternalFrame {

    /**
     * Creates new form iFrmVisualizarImagen
     */
    private String imagenPath = "";

    public iFrmVisualizarImagen(String imagenPath) {
        initComponents();
        this.imagenPath = imagenPath;
        this.setSize((int) frmPrincipal.dskpPrincipal.getWidth() - 10, (int) frmPrincipal.dskpPrincipal.getHeight() - 10);
        OperacionesVarias.cerrarVentanaEscape(this);
        this.setVisible(true);
        ImageIcon icono = new ImageIcon(imagenPath);
        
        ImageIcon tmpIcon = new ImageIcon(icono.getImage().getScaledInstance(this.getWidth(), this.getHeight(), Image.SCALE_DEFAULT));
        lblImagen.setIcon(tmpIcon);
        File f=new File(imagenPath);
        this.setTitle("Visualizacion de "+f.getName()
                );
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPopupMenu1 = new javax.swing.JPopupMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();
        Cerrar = new javax.swing.JMenuItem();
        lblImagen = new javax.swing.JLabel();

        jMenuItem2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jpgs/zoom+.png"))); // NOI18N
        jMenuItem2.setText("Zoom 100%");
        jMenuItem2.setToolTipText("");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jPopupMenu1.add(jMenuItem2);

        jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jpgs/zoom-.png"))); // NOI18N
        jMenuItem1.setText("Zoom 50%");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jPopupMenu1.add(jMenuItem1);

        Cerrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jpgs/agt_home.png"))); // NOI18N
        Cerrar.setText("Cerrar");
        Cerrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CerrarActionPerformed(evt);
            }
        });
        jPopupMenu1.add(Cerrar);

        setClosable(true);
        setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/jpgs/Visualizar.png"))); // NOI18N
        setMinimumSize(new java.awt.Dimension(405, 309));

        lblImagen.setComponentPopupMenu(jPopupMenu1);
        lblImagen.setMaximumSize(new java.awt.Dimension(5000, 5000));
        lblImagen.setMinimumSize(new java.awt.Dimension(405, 309));
        lblImagen.setPreferredSize(new java.awt.Dimension(405, 309));
        getContentPane().add(lblImagen, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void CerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CerrarActionPerformed
        dispose();
    }//GEN-LAST:event_CerrarActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed

        this.setSize((int) 700, (int) 500);
        OperacionesVarias.centrar(this);
        ImageIcon icono = new ImageIcon(imagenPath);
        ImageIcon tmpIcon = new ImageIcon(icono.getImage().getScaledInstance(this.getWidth(), this.getHeight(), Image.SCALE_DEFAULT));
        lblImagen.setIcon(tmpIcon);
        this.repaint();
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        this.setSize((int) frmPrincipal.dskpPrincipal.getWidth() - 10, (int) frmPrincipal.dskpPrincipal.getHeight() - 10);
        OperacionesVarias.centrar(this);
        ImageIcon icono = new ImageIcon(imagenPath);
        ImageIcon tmpIcon = new ImageIcon(icono.getImage().getScaledInstance(this.getWidth(), this.getHeight(), Image.SCALE_DEFAULT));
        lblImagen.setIcon(tmpIcon);
    }//GEN-LAST:event_jMenuItem2ActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem Cerrar;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JPopupMenu jPopupMenu1;
    private javax.swing.JLabel lblImagen;
    // End of variables declaration//GEN-END:variables
}
